package com.zking.dao.mapper;

import com.zking.dao.domain.Department;
import com.zking.dao.domain.Doc_schedule;
import com.zking.dao.domain.Doctor;
import com.zking.dao.domain.SysResources;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

@Repository
public interface DoctorMapper {


    //@ResultMap(value = "BaseResultMap")
    @Select("SELECT * FROM doctor")
    List<Doctor> queryDoctors();

    @Delete("delete FROM doctor where id = #{id}")
    int deleteDoctor(int id);

    @Insert("insert into doctor values (null,#{dname},#{sex},#{age},#{price},#{ppic},#{deptid},#{resume},#{tel})")
    int insertDoctor(Doctor doctor);

    @Update("update doctor set dname=#{dname},sex=#{sex}," +
            "age=#{age},price=#{price}" +
            ",deptid=#{deptid}" +
            ",resume=#{resume},tel=#{tel}" +
            " where id= #{id}")
    int updateDoctor(Doctor doctor);

   // @ResultMap(value = "BaseResultMap")
    @Select("SELECT * FROM doctor where id = #{id}")
    Doctor queryDoctor(int id);


    @Select("select * from department")
    List<Department> queryDepartments();

    @Select("SELECT * FROM doctor where deptid = #{deptid}")
    List<Doctor> department_doctor(int deptid);

    //删除原有值班
    @Delete("delete from doc_schedule where did=#{doctorId} and daytime=#{daytime}")
    boolean delete_Schedule(int doctorId,String daytime);

    //加入上午值班的信息
    @Insert("insert into doc_schedule values(null,#{doctor_id},#{doctor_name},#{dept_id},#{date}," +
            "4,4,4,4,0,0,0,0,#{time_interval})")
    boolean addSchedule_morning(int doctor_id,String doctor_name,int dept_id,String date,int time_interval);
    //加入下午值班的信息
    @Insert("insert into doc_schedule values(null,#{doctor_id},#{doctor_name},#{dept_id},#{date}," +
            "0,0,0,0,4,4,4,4,#{time_interval})")
    boolean addSchedule_afternoon(int doctor_id,String doctor_name,int dept_id,String date,int time_interval);
    //加入全天值班的信息
    @Insert("insert into doc_schedule values(null,#{doctor_id},#{doctor_name},#{dept_id},#{date}," +
            "4,4,4,4,4,4,4,4,#{time_interval})")
    boolean addSchedule(int doctor_id,String doctor_name,int dept_id,String date,int time_interval);

    //查出从明天开始的8天内的数据
    @Select("SELECT * FROM doc_schedule where daytime=#{day1} or daytime=#{day2} or daytime=#{day3} or daytime=#{day4} or daytime=#{day5} or daytime=#{day6} or daytime=#{day7} or daytime=#{day8}")
    List<Doc_schedule> queryDoc_schedules(String day1,String day2,String day3,String day4,String day5,String day6,String day7,String day8,int deptid);



}
